package com.lcx.movie.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lcx.movie.entity.MovieFavorites;
import com.lcx.movie.entity.User;
import com.lcx.movie.mapper.MovieFavoritesMapper;
import com.lcx.movie.mapper.UserMapper;
import com.lcx.movie.service.MovieFavoritesService;
import com.lcx.movie.service.UserService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 李丽君
 * @version 1.0
 * @Description 喜欢的电影实现类
 * @date 2025/2/27 10:28
 */
@Service
public class MovieFavoritesServiceImpl extends ServiceImpl<MovieFavoritesMapper, MovieFavorites> implements MovieFavoritesService {
    @Autowired
    private MovieFavoritesMapper movieFavoritesMapper;

    /**
     * 前台新增我的收藏电影
     * @param movieFavorites 电影收藏实体
     * @return 受影响的行数
     */
    @Override
    public int insertMovieFavorites(MovieFavorites movieFavorites){
        return movieFavoritesMapper.insert(movieFavorites);
    }
    /**
     * 前台根据用户id查询我的收藏电影
     * @param userId 用户id
     * @return 收藏的电影集合
     */
    @Override
    public List<MovieFavorites> selectMovieFavoritesList(Integer userId){
        return movieFavoritesMapper.selectMovieFavoritesList(userId);
    }
    /**
     * 前台根据收藏的电影id取消收藏电影
     * @param movieId 电影id
     * @return 受影响的行数
     */
    @Override
    public int deleteFavorite(Integer movieId){
        return movieFavoritesMapper.deleteFavorite(movieId);
    }
    /**
     * 前台  收藏前判断该用户此影片是否已经收藏过
     * @param userId 用户id
     * @param movieId 电影id
     * @return 受影响的行数
     */
    @Override
    public int checkMovieFavorite(@Param("userId") Integer userId, @Param("movieId") Integer movieId){
        return movieFavoritesMapper.checkMovieFavorite(userId, movieId);
    }
    /**
     * 主页面的最受期待
     * @return 最受期待的电影集合
     */
    @Override
    public List<MovieFavorites> mostExpectedMovies(){
        return movieFavoritesMapper.mostExpectedMovies();
    }

    /**
     * 根据用户名或者影片名查询收藏的电影
     * @param userName 用户名
     * @param movieCnName 电影名
     * @return 收藏电影集合
     */
    @Override
    public List<MovieFavorites> selectMovieFavorites(@Param("userName")String userName,@Param("movieCnName")String movieCnName){
        return movieFavoritesMapper.selectMovieFavorites(userName,movieCnName);
    }

}
